﻿using BLL;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BankSysDemo.WebUI
{
    public partial class EditUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["clientid"] != null)
            {
                TextBox1.Text = Session["clientid"].ToString();
                if (!IsPostBack)
                {
                    //首次加载
                    UserModel model = UserManage.GetUserByClientID(Session["clientid"].ToString());
                    TextBox3.Text = model.name;
                    TextBox4.Text = model.phone;
                    TextBox5.Text = model.address;
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            UserModel model = new UserModel();
            model.clientid = TextBox1.Text;
            model.name = TextBox3.Text;
            model.phone = TextBox4.Text;
            model.address = TextBox5.Text;
            if (UserManage.SaveClient(model))
            {
                //保存成功
                Response.Write("<script>alert('保存成功')</script>");
            }
            else
            {
                //保存失败
                Response.Write("<script>alert('保存失败')</script>");
            }
        }
    }
}